import { Body, Controller, Get, Inject, Post } from '@nestjs/common';
import { UserService } from './user.service';
import { UpdateUserDto } from './dto/update.dto';
import { ListDto } from './dto/list.dto';
import { Payload } from 'src/common/decorators/payload.decorator';
import { GlobalAPI } from 'src/common/typings/global';

@Controller('user')
export class UserController {
  @Inject(UserService)
  private readonly userService: UserService;

  @Post('update')
  async updateUser(@Body() updateDto: UpdateUserDto) {
    return await this.userService.update(updateDto);
  }

  @Post('list')
  async listUser(@Body() listDto: ListDto) {
    return await this.userService.list(listDto);
  }

  @Get('menu')
  async getMenu(@Payload() payload) {
    return await this.userService.getMenu(payload);
  }

  @Get('payload')
  getPayload(@Payload() payload) {
    return payload as GlobalAPI.PayloadProps;
  }
}
